<template>
  <j-modal
    :title="title"
    :width="980"
    :visible="visible"
    :confirmLoading="confirmLoading"
    switchFullscreen
    :okButtonProps="{style:{display:'none'}}"
    @cancel="handleCancel"
    cancelText="关闭">

    <a-card :bordered="false">
      <div>
        <a-table
          ref="table"
          size="middle"
          bordered
          rowKey="id"
          :columns="columns"
          :dataSource="dataSource"
          :pagination="ipagination"
          :loading="loading"
          class="j-table-force-nowrap"
          :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
          @change="handleTableChange"
          >

        <!--<span slot="action" slot-scope="text, record">-->

          <!--<a v-if="record.defaultStatus===0" @click="handleDelete(record)">删除</a>-->
        <!--</span>-->

        </a-table>
      </div>

    </a-card>

  </j-modal>

</template>

<script>
import '@/assets/less/TableExpand.less'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import {deleteAction, getAction, postAction} from "@api/manage";
import pick from "lodash.pick";


export default {
  name: "StmMemberAddressList",
  mixins: [JeecgListMixin],
  data() {
    return {
      refKeys: ['stmStoreSalesRelation', ],
      storeId:'',
      description: '经销商列表页面',
      visible: false,
      confirmLoading: false,
      title:'',
      // 表头
      columns: [
        {
          title: '编号',
          align: 'center',
          dataIndex: 'customerCode'
        },
        {
          title: '收货人',
          align: 'center',
          dataIndex: 'name'
        },
        {
          title: '收货人电话',
          align: 'center',
          width: 120,
          dataIndex: 'phoneNumber'
        },
        {
          title: '收货人所在地',
          align: 'center',
          dataIndex: 'address'
        },
        {
          title: '详细地址',
          align: 'center',
          dataIndex: 'detailAddress'
        },
        // {
        //   title: '距离',
        //   align: 'center',
        //   dataIndex: 'distance'
        // },
        // {
        //   title: '是否默认',
        //   align: 'center',
        //   dataIndex: 'defaultStatusStr'
        // }
        // ,
        // {
        //   title: '操作',
        //   dataIndex: 'action',
        //   align: 'center',
        //   scopedSlots: { customRender: 'action' }
        // }
      ],
      url: {
        list: '/ums/UmsMemberReceiveAddress/list',
        delete: '/ums/UmsMemberReceiveAddress/delete'
      }
    }
  },
  methods: {
    init(record){
      this.storeId=record.storeId;
      this.loadData(1);
      this.visible = true;
    },
    loadData(arg) {
      if (arg === 1) {
        this.ipagination.current = 1;
      }
      let addressModel={};
      addressModel.memberId=this.storeId;
      getAction(this.url.list, {
        memberId: this.storeId
        , pageNo: this.ipagination.current, pageSize: this.ipagination.pageSize
      }).then((res) => {
        if (res.success) {
          this.dataSource = res.result.records
          this.ipagination.total = res.result.total
        } else {
          this.dataSource = null
        }
      })
    },
    close(){
      this.$emit('close')
      this.visible = false
    },
    handleCancel() {
      this.close();
    },
    handleDelete(record){
      console.log(2222)
      deleteAction(this.url.delete, {id: record.id}).then((res) => {
        if (res.success) {
          this.$message.success(res.message)
          this.loadData(1);
        } else {
          this.$message.warning(res.message)
        }
      }).finally(() => {
        this.loading = false
      })
    }
  }
}
</script>

<style scoped>

</style>